// pages/list/listdetail/listdetail.js
var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    active: 0,
    cateList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    console.log(options)
    if(options.id) {
      console.log(1)
    }
    that.init()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 页面初始化
   */
  init: function() {
    let that = this
    wx.showLoading({
      mask: true,
      title: app.globalData.loadText,
    })
    wx.request({
      url: app.globalData.hostAPI + '/v1/service-category/more',
      success: res => {
        if(res.data.status === 1) {
          that.setData({
            cateList: res.data.data.list
          })
        }
        wx.hideLoading()
      }
    })
  },

  /**
   * 
   */
  itemChange: function(e) {
    console.log(e)
    this.setData({
      active: e.currentTarget.dataset.index
    });
  },

  /**
   * goProList
   */
  goProList: function(e) {
    let that = this,
        cid = e.currentTarget.id
    wx.navigateTo({
      url: '../product/list/list?cid=' + cid,
    })
  }
})